package com.itheima.mysort;

public class A04_RecursionDemo1 {
    public static void main(String[] args) {
        //用递归求1~100之间的和

        int num=100;
        int sum = getSum(num);
        System.out.println(sum);
    }

    public static int getSum(int num) {
        //递归出口
        if(num==1){
            return 1;
        }
        //拆解问题
        return num+getSum(num-1);
    }
}
